/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gatewinapp;

import java.net.URL;

/**
 *
 * @author Administrator
 */
public class HTMLDoc {
    private String title = "";
    private String content = "";
    private String line = "<br>";
    public HTMLDoc()
    {
        
    }
    
    public void setTitle(String t)
    {
        title = t;
    }
    
    public String getTitle()
    {
        return title;
    }
    
    public void setContent(String c)
    {
        content = c;
    }
    
    public void addDoc(String name, URL sourceURL, String body, String[] array_key)
    {
        content += "<a href=\"file://" + sourceURL.getPath() + "\"><b>" + name + "</b></a>" + line;
        FormatText ft = new FormatText(body);
        for (int j = 0; j < array_key.length; j++)
        {
            String[] left = ft.leftContent(array_key[j]);
            String[] actualText = ft.actualText(array_key[j]);
            String[] right = ft.rightContent(array_key[j]);
            int count = ft.countFrequency(array_key[j]);
            for (int i = 0; i < count; i++)
            {
                content += left[i] + "<b>" + actualText[i] + "</b> " + right[i] + "... ";
                if (content.length() > 400) {
                    break;
                }
            }
            content += line;
        }
        content += line;
    }
    
    public String genDoc()
    {
        String result = "<html><body><div>" + content + "</div></body></html>";
                   
        return result;
    }
}
